package com.yanqu.road.entity.unioncampwar.center;


import com.alibaba.fastjson.JSONObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.servercenter.ChannelSystemConfig;
import com.yanqu.road.entity.servergroup.ICrossServerGroup;
import com.yanqu.road.utils.string.StringUtils;
import org.apache.mina.util.ConcurrentHashSet;

import java.util.*;

/**
 * 商帮分组数据,后台配置,改成从t_s_system_config表加载进来
 */
public class CenterUnionCampWarGroupData {
    private int groupId;
    private int channelId;
    private int groupPerNum;
    private int minServerNum;
    private int unionNum;
    private boolean isNeedActive;
    private int startOpenDay;
    private int endOpenDay;

    private Map<String, String> configMap = new HashMap<>();


    //    @FieldTypeAnnotation(desc = "参与区服")由读配置改成分组时设置进去
    private Set<Long> serverSet = new ConcurrentHashSet<>();

    public int getGroupId() {
        return groupId;
    }

    public List<Long> getServerList() {
        return new ArrayList<>(serverSet);
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public int getChannelId() {
        return channelId;
    }

    public void setChannelId(int channelId) {
        this.channelId = channelId;
    }

    public Set<Long> getServerSet() {
        return serverSet;
    }

    public void setServerSet(Set<Long> serverSet) {
        this.serverSet = serverSet;
    }

    public void setServerSet(List<Long> serverSet) {
        this.serverSet.clear();
        this.serverSet.addAll(serverSet);
    }

    public void addServerSet(Set<Long> serverSet) {
        for (Long serverId : serverSet) {
            this.serverSet.add(serverId);
        }
    }

    public int getStartOpenDay() {
        return startOpenDay;
    }

    public void setStartOpenDay(int startOpenDay) {
        this.startOpenDay = startOpenDay;
    }

    public int getEndOpenDay() {
        return endOpenDay;
    }

    public void setEndOpenDay(int endOpenDay) {
        this.endOpenDay = endOpenDay;
    }

    public int getGroupPerNum() {
        return groupPerNum;
    }

    public void setGroupPerNum(int groupPerNum) {
        this.groupPerNum = groupPerNum;
    }

    public int getMinServerNum() {
        return minServerNum;
    }

    public void setMinServerNum(int minServerNum) {
        this.minServerNum = minServerNum;
    }

    public int getUnionNum() {
        return unionNum;
    }

    public void setUnionNum(int unionNum) {
        this.unionNum = unionNum;
    }

    public boolean isNeedActive() {
        return isNeedActive;
    }

    public void setNeedActive(boolean needActive) {
        isNeedActive = needActive;
    }

    public void initSHANGBANG_REWARD_RESULT(ChannelSystemConfig systemConfig) {
        String[] split = systemConfig.getValue().split("\\|");
        for (String s : split) {
            String[] split1 = s.split(":");
            int matchDay = Integer.parseInt(split1[0]);
            if (this.startOpenDay < matchDay) {
                break;
            }
            this.configMap.put(systemConfig.getParam(), split1[1]);
        }
    }

    public void initSHANGBANG_HOLD_WIN_EXTRA_REWARD(ChannelSystemConfig systemConfig) {
        String[] split = systemConfig.getValue().split("\\|");
        for (String s : split) {
            String[] split1 = s.split(":");
            int matchDay = Integer.parseInt(split1[0]);
            if (this.startOpenDay < matchDay) {
                break;
            }
            this.configMap.put(systemConfig.getParam(), split1[1]);
        }
    }

    public void initSHANGBANG_LOTTERY_GENERA(ChannelSystemConfig systemConfig) {
        String[] split = systemConfig.getValue().split("\\|");
        for (String s : split) {
            String[] split1 = s.split(":");
            int matchDay = Integer.parseInt(split1[0]);
            if (this.startOpenDay < matchDay) {
                break;
            }
            this.configMap.put(systemConfig.getParam(), split1[1]);
        }
    }

    public void initSHANGBANG_LOTTERY_SPECIAL(ChannelSystemConfig systemConfig) {
        String[] split = systemConfig.getValue().split("\\|");
        for (String s : split) {
            String[] split1 = s.split(":");
            int matchDay = Integer.parseInt(split1[0]);
            if (this.startOpenDay < matchDay) {
                break;
            }
            this.configMap.put(systemConfig.getParam(), split1[1]);
        }
    }

    public void initSHANGBANG_LOTTERY_COST(ChannelSystemConfig systemConfig) {
        this.configMap.put(systemConfig.getParam(), systemConfig.getValue());
    }

    public void initMinOpenDay(int minOpenDay) {
        this.configMap.put("SHANGBANG_OPEN_DAY", String.valueOf(minOpenDay));
    }

    public Map<String, String> getConfigMap() {
        return configMap;
    }
}
